﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Billing.WindowsBase;

namespace Billing.Windows.Shell
{
    public partial class FontConverterForm : FormBase
    {
        ConverterBase cb = new ConverterBase();
        public FontConverterForm()
        {
            InitializeComponent();
            this.cmbFrom.Items.Clear();
            this.cmbTo.Items.Clear();

            foreach (string var in cb.FontList.Keys)
            {
                this.cmbFrom.Items.Add(var);
                this.cmbTo.Items.Add(var);
            }
            this.cmbFrom.SelectedIndex = 0;
            this.cmbTo.SelectedIndex = 0;
            cb.BeforeConvert += new BeforeConvertHandler(cb_BeforeConvert);
            cb.Convert += new ConvertHandler(cb_Convert);
            cb.AfterConvert += new AfterConvertHandler(cb_AfterConvert);
        }

        void cb_AfterConvert()
        {
            this.PB.Maximum = 0;
        }

        void cb_Convert(int Value)
        {
            this.PB.Value = Value;
        }

        void cb_BeforeConvert(int MaxValue)
        {
            this.PB.Maximum = MaxValue;
        }

        private void btnConvert_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                cb.ChangeFontExcel(this.chkCheckFont.Checked, this.cmbFrom.Text, cmbTo.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }

        }

        private void chkCheckFont_CheckedChanged(object sender, EventArgs e)
        {
            this.cmbFrom.Enabled = !this.chkCheckFont.Checked;
        }
    }
}

